import { IPSAppDEView } from '../../app/view/ipsapp-deview';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { PSControlImpl } from '../pscontrol-impl';
import { IPSDEViewPanel } from './ipsdeview-panel';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSDEViewPanelImpl extends PSControlImpl implements IPSDEViewPanel {
  protected cappslanguageres: IPSLanguageRes | null = null;

  getCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.cappslanguageres != null) return this.cappslanguageres;
    const value = this.M.getCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.cappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getCapPSLanguageRes') as IPSLanguageRes;
    return this.cappslanguageres;
  }

  get capPSLanguageRes(): IPSLanguageRes | null {
    return this.getCapPSLanguageRes();
  }

  getCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源对象');
    }
    return value;
  }

  get caption(): string {
    return this.M.caption;
  }

  protected embeddedpsappdeview: IPSAppDEView | null = null;

  getEmbeddedPSAppDEView(): IPSAppDEView | null {
    if (this.embeddedpsappdeview != null) return this.embeddedpsappdeview;
    const value = this.M.getEmbeddedPSAppDEView;
    if (value == null) {
      return null;
    }
    this.embeddedpsappdeview = this.getPSModel4('app.view.IPSAppDEView', value, 'getEmbeddedPSAppDEView') as IPSAppDEView;
    return this.embeddedpsappdeview;
  }

  get embeddedPSAppDEView(): IPSAppDEView | null {
    return this.getEmbeddedPSAppDEView();
  }

  getEmbeddedPSAppDEViewMust(): IPSAppDEView {
    const value = this.getEmbeddedPSAppDEView();
    if (value == null) {
      throw new Error('未指定嵌入视图对象');
    }
    return value;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  get cls(): string {
    return 'PSDEViewPanelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSNavigateParamContainer' || cls == 'control.viewpanel.IPSDEViewPanel') return true;
    return super.instanceof(cls);
  }
}
